#include "./parts.h"
#include "../../device/gpio.h"

namespace driver {

using namespace device::gpio;

using PUMP = PB<0>;
using VALVE = PB<9>;
using FAN = PB<12>;
using DROP_ICE = PB<10>;

Parts::Parts() {
    RCC->APB2ENR |= RCC_APB2ENR_IOPBEN;

    config_pp_out<PUMP, VALVE, FAN, DROP_ICE>();
}

void Parts::open_pump() {
    PUMP::set();
    m_pump_flag = true;
}

void Parts::close_pump() {
    PUMP::clr();
    m_pump_flag = false;
}

void Parts::open_valve() {
    VALVE::set();
    m_valve_flag = true;
}

void Parts::close_valve() {
    VALVE::clr();
    m_valve_flag = false;
}

void Parts::open_fan() {
    FAN::set();
    m_fan_falg = true;
}

void Parts::close_fan() {
    FAN::clr();
    m_fan_falg = false;
}

void Parts::open_drop_ice() {
    DROP_ICE::set();
    m_drop_ice_flag = true;
}

void Parts::close_drop_ice() {
    DROP_ICE::clr();
    m_drop_ice_flag = false;
}


}

